//=============================================================================
// Terrain_Heightmap.h by Frank Luna (C) 2004 All Rights Reserved.
//=============================================================================

#ifndef HEIGHTMAP_H
#define HEIGHTMAP_H

#include "Table.h"
#include <string>

class Terrain_Heightmap
{
public:
	Terrain_Heightmap();
	Terrain_Heightmap(int m, int n);
	Terrain_Heightmap(int m, int n, const tstring& filename, float heightScale, float heightOffset);

	void Recreate(int m, int n);

	void LoadRAW(int m, int n,
		const tstring& filename, float heightScale, float heightOffset);
	void LoadRAW16(int m, int n,
		const tstring& filename, float heightScale, float heightOffset);

	int NumRows()const;
	int NumCols()const;

	float GetHeight(int i, int j)const;


private:
	bool  InBounds(int i, int j);
	float SampleHeight3x3(int i, int j);
	void  Filter3x3();
private:
	tstring  m_HeightMapFilename;
	Table<float> m_HeightMap;
	float        m_HeightScale;
	float        m_HeightOffset;
};

#endif //HEIGHTMAP_H